/*
 * Created by SharpDevelop.
 * User: daniel
 * Date: 12/25/2006
 * Time: 8:45 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;

namespace MonoDoku
{
	/// <summary>
	/// Description of Utility.
	/// </summary>
	public class Utility
	{
		public static string version_number = "1.0";
		
		public Utility()
		{
		}
		
		public static int grid_width( int[,] grid ){
			return grid.GetUpperBound( 0 ) + 1;
		}
		
		public static int grid_height( int[,] grid ){
			return grid.GetUpperBound( 1 ) + 1;
		}
		
		public static int grid_width( Object[,] grid ){
			return grid.GetUpperBound( 0 ) + 1;
		}
		
		public static int grid_height( Object[,] grid ){
			return grid.GetUpperBound( 1 ) + 1;
		}
		
		public static int[,] grid_copy( int[,] grid ){
			int width = grid_width( grid );
			int height = grid_height( grid );
			int[,] toReturn = new int[ width, height ];
			
			for( int i = 0; i < width; i++ ){
				for( int j = 0; j < height; j++ ){
					toReturn[i,j] = grid[i,j];
				}
			}
			
			return toReturn;
		}
		
		public static int[,] default_groups( int dimension ){
			int[,] toReturn = new int[ dimension, dimension ];
			int sqrt = (int) Math.Sqrt( dimension );
			
			
			for(int x= 0; x < dimension; x++){
				for( int i = 0; i < sqrt; i++ ){
					for( int y = 0; y < sqrt; y++) {
						
						
						toReturn[x , y + i*sqrt ] = x/sqrt + i*sqrt + 1;
					}
				}
			}
			return toReturn;
		}
	}
}
